{{ $incidents := where .Site.RegularPages "Params.section" "issue" }}
{{ $active := where $incidents "Params.resolved" "=" false }}

{{ $isNotice := where $active "Params.severity" "=" "notice" }}
{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}
{{ $isDown := where $active "Params.severity" "=" "down" }}

<a href="{{ .Permalink }}" class="issue no-underline">
  {{ if .Params.informational }}

  <small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "2006-01-02T15:04:05Z" }}">
      {{ if .Site.Params.dateFormat }}
        {{ dateFormat .Site.Params.dateFormat .Params.date }}
      {{ else }}
        {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
      {{ end }}
    </small>

    <h3>
      {{ .Title }}  ℹ
    </h3>

  {{ else if .Params.Resolved }}
    <small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "2006-01-02T15:04:05Z" }}">
      {{ if .Site.Params.dateFormat }}
        {{ dateFormat .Site.Params.dateFormat .Params.date }}
      {{ else }}
        {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
      {{ end }}
    </small>

    <h3>
      {{ .Title }}
    </h3>

    {{ $t := (time .Params.ResolvedWhen) }}
    {{ $timeDiff := (sub $t.Unix .Date.Unix) }}
    {{ $diffInMin := (div $timeDiff 60) }}

    <!-- Marker -->
	{{ $t := (time .Params.ResolvedWhen) }}
	{{ $timeDiff := (sub $t.Unix .Date.Unix) }}
	{{ $days := div $timeDiff 86400 }}
	{{ $remainingSeconds := mod $timeDiff 86400 }}
	{{ $hours := div $remainingSeconds 3600 }}
	{{ $minutes := div (mod $remainingSeconds 3600) 60 }}

	<div
		class="{{ if lt $timeDiff 60 }}faded{{ else if gt $days 0 }}warning{{ else if gt $hours 0 }}warning{{ else }}ok{{ end }}">
		{{ if lt $timeDiff 60 }}
		{{ T "resolved" }}
		{{ T "inUnderAMinute" }}
		{{ else }}
		{{ T "resolvedAfter" }} {{ if gt $days 0 }}{{ $days }}d {{ end }}
		{{ if gt $hours 0 }}{{ $hours }}h {{ end }}
		{{ $minutes }}m
		{{ if eq .Params.severity "down" }}
		{{ T "ofDowntime" }}
		{{ end }}
		{{ end }}
	</div>

  {{ else }}
  <!-- If not resolved -->
    <small class="date float-right {{ cond .Site.Params.useRelativeTime "relative-time" "" }}" title="{{ dateFormat .Site.Params.dateFormat .Params.date }}" data-date="{{ .Date.Format "2006-01-02T15:04:05Z" }}">

      {{ if .Date.Before now }}
        {{ if .Site.Params.dateFormat }}
          {{ dateFormat .Site.Params.dateFormat .Params.date }}
        {{ else }}
          {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
        {{ end }}
      {{ else }}
      {{ end }}
    </small>

    <h3>
      {{ .Title }}
    </h3>



    <!-- Marker -->
    {{ if eq .Params.severity "notice" }}
      <strong class="error">
        ◆
        {{ if .Date.Before now }}
          {{ T "downtimeOngoing" }}
        {{ else }}
          {{ if .Site.Params.dateFormat }}
            {{ dateFormat .Site.Params.dateFormat .Params.date }}
          {{ else }}
            {{ .Date.Format "January 2, 2006 at 3:04 PM" }}
          {{ end }}
        {{ end }}
      </strong>
    {{ else }}
		<strong>
		{{ if eq .Params.severity "down" }}
		<span style="color: {{ .Site.Params.down }}">■ {{ T "thisIsDown" }}</span>
		{{ else if eq .Params.severity "disrupted" }}
		<span style="color: {{ .Site.Params.disrupted }}">▲ {{ T "thisIsDisrupted" }}</span>
		{{ else }}
		<span style="color: {{ .Site.Params.notice }}">◆ {{ T "thisIsNotice" }}</span>
		{{ end }}
		</strong>
		<span class="faded">
			– {{ T "downtimeOngoing" }}
		</span>
    {{ end }}

  {{ end }}
</a>
